<template>
	<view>
		<float url="/pages/common/signin/signin" image="/static/images/chat/emoji/60a.jpg"></float>
		<!--<import src="/templates/login/index.wxml"></import>-->
		<view class="container">
			<view v-if="apiUserInfoMap" class="userinfo">
				<image v-if="apiUserInfoMap.headimgurl" class="userinfo-avatar" :src="apiUserInfoMap.headimgurl" background-size="cover"></image>
				<text class="userinfo-nickname">{{ apiUserInfoMap.nickname }}</text>
				<navigator class="user_updata" url="/pages/ucenter/updata_userInfo/updata_userInfo">完善资料</navigator>
			</view>
			<view v-else class="userinfo" style="margin-bottom:50rpx;">
				<image class="userinfo-avatar" src="/static/images/constant/nologin.png" background-size="cover"></image>
				<button class="weui-btn mini-btn" plain="true" size="mini" @click="showLogin">点击登录账户
				</button>
			</view>
			<!-- <view wx:if="{{ !ttVetOpen }}" class="asset">
        <view class='item' bindtap='goAsset'>
          <view>{{balance}}</view>
          <view>余额</view>
        </view>
        <view class='item right' bindtap='goAsset'>
          <view>{{freeze}}</view>
          <view>冻结</view>
        </view>
        <view class='item right' bindtap='goScore'>
          <view>{{score}}</view>
          <view>积分</view>
        </view>
        <navigator url="/pages/score/growth">
          <view class='item right'>
            <view>{{growth}}</view>
            <view>成长值</view>
          </view>
        </navigator>
      </view> -->
			<!-- <view class="constant-space"></view>
      <navigator url="/pages/order-list/index">
        <view class="menu-item">
          <view class="l">我的订单</view>
          <image class="next" src="/images/constant/icon/next.png"></image>
        </view>
      </navigator>
      <view class="liconstant-linene"></view>
      <view class='order-shortcut'>
        <view class='item' bindtap='goOrder' data-type="0">
          <image class="icon" src="/images/constant/order/topay.png" background-size="cover"></image>
          <view class='text'>待付款</view>
        </view>
        <view class='item' bindtap='goOrder' data-type="1">
          <image class="icon" src="/images/constant/order/fahuo.png" background-size="cover"></image>
          <view class='text'>待发货</view>
        </view>
        <view class='item' bindtap='goOrder' data-type="2">
          <image class="icon" src="/images/constant/order/shouhuo.png" background-size="cover"></image>
          <view class='text'>待收货</view>
        </view>
        <view class='item' bindtap='goOrder' data-type="3">
          <image class="icon" src="/images/constant/order/pj.png" background-size="cover"></image>
          <view class='text'>待评价</view>
        </view>
        <view class='item' bindtap='goOrder' data-type="99">
          <image class="icon" src="/images/constant/order/shouhou.png" background-size="cover"></image>
          <view class='text'>退款/售后</view>
        </view>
      </view> -->
			<!-- flex布局的新菜单 -->
			<!-- <view class="menu-item">
        <view class="l">我的订单</view>
        <image class="next" src="/images/icon/next.png"></image>
      </view>
      <view class="constant-space"></view>
      <view class="constant-line"></view>
      <view class="menu-item">
        <view class="l">我的订单</view>
        <view class="r">内容</view>
      </view>
      <view class="constant-line"></view>
      <view class="menu-item">
        <view class="l">我的订单</view>
        <view class="r">内容</view>
      </view> -->
			<!-- <block wx:if="{{!ttVetOpen && vipLevel > 0}}">
        <view class="constant-space"></view>
        <navigator wx:if="{{!apiUserInfoMap.base.isSeller}}" url="/pages/fx/apply-status">
          <view class="menu-item">
            <view class="l">成为分销商</view>
            <image class="next" src="/images/constant/icon/next.png"></image>
          </view>
        </navigator>
        <navigator wx:else url="/pages/fx/apply-status">
          <view class="menu-item">
            <view class="l">分销中心</view>
            <image class="next" src="/images/constant/icon/next.png"></image>
          </view>
        </navigator>
        <view wx:if="{{apiUserInfoMap.base.isSeller}}" class="constant-line"></view>
        <navigator wx:if="{{apiUserInfoMap.base.isSeller}}" url="/pages/fx/members">
          <view class="menu-item">
            <view class="l">我的团队</view>
            <image class="next" src="/images/constant/icon/next.png"></image>
          </view>
        </navigator>
        <view wx:if="{{apiUserInfoMap.base.isSeller}}" class="constant-line"></view>
        <navigator wx:if="{{apiUserInfoMap.base.isSeller}}" url="/pages/fx/commisionLog">
          <view class="menu-item">
            <view class="l">返佣明细</view>
            <image class="next" src="/images/constant/icon/next.png"></image>
          </view>
        </navigator>
      </block> -->
			<view class="constant-space"></view>
			<navigator url="/pages/ucenter/mine/mine" v-if="isShow">
				<view class="menu-item">
					<view class="l">我的招工</view>
					<image class="next" src="/static/images/constant/icon/next.png"></image>
				</view>
			</navigator>
			<view class="constant-line"></view>
			<navigator url="/pages/ucenter/recruit/recruit">
				<view class="menu-item">
					<view class="l">我的名片</view>
					<image class="next" src="/static/images/constant/icon/next.png"></image>
				</view>
			</navigator>
			<view class="constant-line"></view>
			<navigator url="/pages/ucenter/message/message" v-if="isShow">
				<view class="menu-item">
					<view class="l">我的消息</view>
					<view class="next">
						<view v-if="message > 0" class="message">{{message}}</view>
						<image v-if="message == 0" src="/static/images/constant/icon/next.png"></image>
					</view>
				</view>
			</navigator>
			<!-- <view class="constant-line"></view>
      <navigator url="/pages/invoice/list">
        <view class="menu-item">
          <view class="l">我的收藏</view>
          <image class="next" src="/images/constant/icon/next.png"></image>
        </view>
      </navigator> -->
			<view class="constant-space"></view>
			<!-- <navigator url="/pages/maidan/index">
        <view class="menu-item">
          <view class="l">获取积分</view>
          <image class="next" src="/images/constant/icon/next.png"></image>
        </view>
      </navigator> -->
			<view class="constant-line"></view>
			<navigator url="/pages/ucenter/integral/integral" v-if="isShow">
				<view class="menu-item">
					<view class="l">我的积分</view>
					<image class="next" src="/static/images/constant/icon/next.png"></image>
				</view>
			</navigator>
			<!-- <view class="constant-line"></view> -->
			<!-- <navigator url="/pages/sign/index">
        <view class="menu-item">
          <view class="l">积分消耗记录</view>
          <image class="next" src="/images/constant/icon/next.png"></image>
        </view>
      </navigator> -->
			<!-- <view class="constant-line"></view> -->
			<!-- <navigator url="/pages/score-excharge/index">
        <view class="menu-item">
          <view class="l">积分来源记录</view>
          <image class="next" src="/images/constant/icon/next.png"></image>
        </view>
      </navigator> -->
			<view class="constant-space"></view>
			<navigator url="/pages/ucenter/collect/collect" v-if="isShow">
				<view class="menu-item" @tap="aboutUs">
					<view class="l">我的收藏</view>
					<image class="next" src="/static/images/constant/icon/next.png"></image>
				</view>
			</navigator>
			<view class="constant-space"></view>
			<button plain open-type="feedback" class="a" v-if="isShow">
				<view class="menu-item">
					<view class="l">意见反馈</view>
					<image class="next" src="/static/images/constant/icon/next.png"></image>
				</view>
			</button>
			<view class="constant-line"></view>
			<view class="menu-item" @tap="aboutUs" v-if="isShow">
				<view class="l">帮助中心</view>
				<image class="next" src="/static/images/constant/icon/next.png"></image>
			</view>
			<!-- <view class="constant-line"></view>
      <view class="menu-item">
        <view class="l">绑定官网账号</view>
        <image class="next" src="/images/constant/icon/next.png"></image>
      </view> -->
		</view>
		<view v-if="isLogin">
			<view v-if="!apiUserInfoMap" class="userinfo">
				<block data-type="template" data-is="apifmLogin" data-attr="ttlogin: ttlogin">
					<view class="apifmLogin">
						<view class="s-b">
							<view class="s-l-b">
								<image src="/static/images/nologin.png"></image>
								<text>授权登录</text>
							</view>
							<view class="s-t-b">
								<view class="s-t-i">
									<text>·</text>
									请授权小程序登录
								</view>
								<view class="s-t-i">
									<text>·</text>
									我们不会公布您的这些信息
								</view>
								<view class="s-t-i">
									<text>·</text>
									只是为了给您提供更好的服务
								</view>
							</view>
							<!-- <button class="l" open-type="getUserInfo" @bindgetuserinfo="processLogin">允许
              </button> -->
							<button class="l" @tap="processLogin">允许
							</button>
							<button class="c" @click="cancelLogin" type="default">暂不登录
							</button>
						</view>
					</view>
				</block>
			</view>
		</view>
	</view>
</template>

<script>
	let app = getApp();
	import float from "../../../components/float/float";

	export default {
		data() {
			return {
				isShow: false,
				ttlogin: false,
				isLogin: false,
				message: 0,
				apiUserInfoMap: ""
			};
		},

		components: {
			float
		},
		props: {},

		onLoad() {
			var that = this;
			let userInfoParam = uni.getStorageSync('userInfo');

			if (userInfoParam) {
				this.setData({
					ttlogin: true,
					apiUserInfoMap: userInfoParam
				});
			} else {
				this.setData({
					isLogin: true,
					ttlogin: false
				});
			}

			uni.request({
				url: `${app.globalData.baseUrl}/mallappletbackstage/is-show/select/isShow`,
				// 目标服务器url
				method: 'GET',
				header: {
					'content-type': 'application/json'
				},
				success: res => {
					console.log('是否伪装', res.data.dataMap.data);

					if (res.data.dataMap.data.isShow === 1) {
						this.setData({
							isShow: true
						});
					} else {
						this.setData({
							isShow: false
						});
					}
				}
			});
		},

		onShow() {
			let userInfoParam = uni.getStorageSync('userInfo');

			if (userInfoParam) {
				this.setData({
					ttlogin: true,
					apiUserInfoMap: userInfoParam
				});
			} else {
				this.setData({
					isLogin: true,
					ttlogin: false
				});
			}
		},

		methods: {
			onshow: function() {
				var that = this;
				var userInfoParam = uni.getStorageSync('userInfo');
				console.log(userInfoParam);

				if (userInfoParam) {
					this.setData({
						ttlogin: true,
						apiUserInfoMap: userInfoParam
					});
				} else {
					that.setData({
						ttlogin: false
					});
				}

				uni.request({
					url: `${app.globalData.baseUrl}/mallappletbackstage/is-show/select/isShow`,
					// 目标服务器url
					method: 'GET',
					header: {
						'content-type': 'application/json'
					},
					success: res => {
						console.log('是否伪装', res.data.dataMap.data);

						if (res.data.dataMap.data.isShow === 1) {
							this.setData({
								isShow: false
							});
						} else {
							this.setData({
								isShow: true
							});
						}
					}
				});
			},
			showLogin: function() {
				this.setData({
					ttlogin: false,
					isLogin: true,
				});
			},

			cancelLogin: function() {
				this.setData({
					isLogin: false
				});
			},

			processLogin: function(e) {
				// app.globalData.globalHandleLogin(e);
				// this.setData({
				//   apiUserInfoMap: uni.getStorageSync("userInfo")
				// });
				// console.log('qwe', app.globalData.userInfoData);
				// uni.request({
				// 	url: `https://localhost:10000/H5/Oauth`
				// });
				window.location.href =
					"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx022815589dbefd3e&redirect_uri=https://we9.91gongju.cn/wechat/security&response_type=code&scope=snsapi_userinfo&connect_redirect=1#wechat_redirect"
				},

				// getMessage() {
				// 	let openid = uni.getStorageSync('openid');

				// 	let _this = this;

				// 	if (!openid) {
				// 		uni.showToast({
				// 			title: '未登录',
				// 			icon: "none"
				// 		});
				// 	} else {
				// 		uni.request({
				// 			url: `${app.globalData.baseUrl}/user/selectIsUser/${openid}`,
				// 			complete: res => {},
				// 			success: result => {
				// 				uni.request({
				// 					url: `${app.globalData.baseUrl}/message/count/${result.data.dataMap.data.id}`,

				// 					success(res1) {
				// 						console.log("message: " + res1.data.dataMap.data);

				// 						_this.setData({
				// 							message: res1.data.dataMap.data
				// 						});
				// 					}

				// 				});
				// 			}
				// 		});
				// 	}
				// },
				onShareTimeline() {},

			}
		};
</script>
<style>
	@import "../../../templates/login/index.css";

	page,
	view,
	image,
	input {
		display: block;
		box-sizing: border-box;
	}

	.container {
		min-height: 100%;
		overflow: hidden;
		overflow-y: hidden;
	}

	.userinfo {
		display: flex;
		flex-direction: column;
		align-items: center;
		width: 750rpx;
	}

	.userinfo-avatar {
		width: 160rpx;
		height: 160rpx;
	}

	.userinfo-nickname {
		margin-top: 20rpx;
		margin-bottom: 20rpx;
		font-size: 14px;
	}

	.asset {
		display: flex;
		border-top: 1px solid #eee;
		padding-top: 20rpx;
		padding-bottom: 20rpx;
	}

	.asset .item {
		display: flex;
		flex-direction: column;
		width: 187rpx;
		text-align: center;
		font-size: 13px;
		line-height: 20px;
		color: #333;
	}

	.asset .right {
		border-left: 1px solid #eee;
	}

	.order-shortcut {
		display: flex;
		padding-top: 20rpx;
		padding-bottom: 20rpx;
	}

	.order-shortcut .item {
		display: flex;
		flex-direction: column;
		width: 150rpx;
		text-align: center;
	}

	.order-shortcut .item .icon {
		width: 67rpx;
		height: 67rpx;
		margin-left: 45rpx;
	}

	.order-shortcut .item .text {
		font-size: 12px;
	}

	.to-authorize {
		padding: 0rpx;
		margin: 0rpx;
		background: none;
		border: none;
		height: auto;
		line-height: auto;
	}

	/* 绑定手机号 */
	.bind-phone-number {
		margin: 20rpx;
		width: 100%;
	}

	/* flex重新构建菜单 */
	.menu-item {
		width: 686rpx;
		height: 104rpx;
		padding-left: 32rpx;
		padding-right: 32rpx;
		background: #fff;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.menu-item .l {
		font-size: 34rpx;
		color: #333;
		line-height: 104rpx;
	}

	.menu-item .r {
		font-size: 32rpx;
		color: #999;
		line-height: 104rpx;
	}

	.menu-item .next {
		width: 40rpx;
		height: 40rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.menu-item button {
		margin: 0;
	}

	.constant-space {
		width: 100vw;
		height: 16rpx;
		background: #F4F5F9;
	}

	.constant-line {
		width: 718px;
		height: 1px;
		background: #EEEEEE;
		margin-left: 32rpx;
	}

	page,
	view,
	image,
	input {
		display: block;
		box-sizing: border-box;
	}

	.container {
		min-height: 100%;
		overflow: hidden;
		overflow-y: hidden;
	}

	.userinfo {
		display: flex;
		flex-direction: column;
		align-items: center;
		width: 750rpx;
	}

	.userinfo-avatar {
		width: 160rpx;
		height: 160rpx;
	}

	.userinfo-nickname {
		margin-top: 20rpx;
		margin-bottom: 20rpx;
		font-size: 14px;
	}

	.asset {
		display: flex;
		border-top: 1px solid #eee;
		padding-top: 20rpx;
		padding-bottom: 20rpx;
	}

	.asset .item {
		display: flex;
		flex-direction: column;
		width: 187rpx;
		text-align: center;
		font-size: 13px;
		line-height: 20px;
		color: #333;
	}

	.asset .right {
		border-left: 1px solid #eee;
	}

	.order-shortcut {
		display: flex;
		padding-top: 20rpx;
		padding-bottom: 20rpx;
	}

	.order-shortcut .item {
		display: flex;
		flex-direction: column;
		width: 150rpx;
		text-align: center;
	}

	.order-shortcut .item .icon {
		width: 67rpx;
		height: 67rpx;
		margin-left: 45rpx;
	}

	.order-shortcut .item .text {
		font-size: 12px;
	}

	.to-authorize {
		padding: 0rpx;
		margin: 0rpx;
		background: none;
		border: none;
		height: auto;
		line-height: auto;
	}

	/* 绑定手机号 */
	.bind-phone-number {
		margin: 20rpx;
		width: 100%;
	}

	/* flex重新构建菜单 */
	.menu-item {
		width: 686rpx;
		height: 104rpx;
		padding-left: 32rpx;
		padding-right: 32rpx;
		background: #fff;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.menu-item .l {
		font-size: 34rpx;
		color: #333;
		line-height: 104rpx;
	}

	.menu-item .r {
		font-size: 32rpx;
		color: #999;
		line-height: 104rpx;
	}

	.menu-item .next {
		width: 40rpx;
		height: 40rpx;
	}

	.menu-item button {
		margin: 0;
	}

	.constant-space {
		width: 100vw;
		height: 16rpx;
		background: #F4F5F9;
	}

	.constant-line {
		width: 718px;
		height: 1px;
		background: #EEEEEE;
		margin-left: 32rpx;
	}

	.message {
		color: red;
	}

	.a {
		padding: 0;
		border: none !important;
	}

	.user_updata {
		color: blue;
	}
</style>
